// ==========================================================================
// 数据表：sys_configs - 系统接口数据
// ==========================================================================

TABLE_NAME = 'sys_configs';
COLUMN_KEY = 'config_id';
TABLE_FIELDS = '*';

'use api/lib/sql.js';

function getPlaceholders(condition) {
	const columnsArr = Object.keys(condition);
	const placeholders = [];
	const tempParams = [];
	columnsArr.forEach((item) => {
		if (item == 'title') {
			placeholders.push(`title LIKE ?`);
			tempParams.push('%' + condition[item] + '%');
		} else if (item == 'name') {
			placeholders.push(`name = ?`);
			tempParams.push(condition[item]);
		} else if (item == 'isSystem') {
			placeholders.push(`is_system = ?`);
			tempParams.push(condition[item]);
		}
	});

	return {
		placeholders: placeholders.join(' AND '),
		tempParams: tempParams,
	};
}

function main() {
	// 验证用户权限
	'use api/user/acl/excerpt.js'

	switch (payload.get().method) {
		case 'GET':
			break;
		case 'POST':
		case 'PUT':
		case 'DELETE':
			SQL.removeCache( // 清除缓存
				'system_sql',
				"SELECT * FROM `sys_configs` WHERE `delete_time` IS NULL;",
			);
			break;
	}

	return base_curd();
}
